#include <brpc/server.h>
#include <brpc/channel.h>
#include "hello.pb.h"

// 定义一个服务
class EchoServiceImpl : public EchoService {
public:
    void Echo(google::protobuf::RpcController* cntl,
              const EchoRequest* request,
              EchoResponse* response,
              google::protobuf::Closure* done) {
        response->set_message(request->message());
        done->Run();
    }
};

int main() {
    // 启动服务器
    brpc::Server server;

    // 注册服务
    EchoServiceImpl echo_service;
    server.add_service(&echo_service,
                       brpc::SERVER_DOESNT_OWN_SERVICE);

    // 监听端口
    brpc::ServerOptions options;
    server.Start(12345, &options);

    // 进入主循环
    server.RunUntilAskedToQuit();

    return 0;
}